/**
 * 门派和伙伴系统相关API
 */
import { get, post } from './request'

// 门派相关
// 获取门派列表
export function getSectList() {
  return post('/sect/list')
}

// 加入门派
export function joinSect(sectId) {
  return post('/sect/select', {
    sect_id: sectId
  })
}

// 退出门派
export function leaveSect() {
  return post('/sect/leave')
}

// 获取门派信息
export function getSectInfo() {
  return post('/sect/info')
}

// 获取门派技能
export function getSectSkills() {
  return post('/sect/skills')
}

// 学习门派技能
export function learnSectSkill(skillId) {
  return post('/sect/learn_skill', {
    skill_id: skillId
  })
}

// 获取门派成员列表
export function getSectMembers() {
  return post('/sect/members')
}

// 获取门派任务列表
export function getSectTasks() {
  return post('/sect/tasks')
}

// 获取门派活动
export function getSectActivities() {
  return post('/sect/activities')
}

// 接受门派任务
export function acceptSectTask(taskId) {
  return post('/sect/accept_task', {
    task_id: taskId
  })
}

// 完成门派任务
export function completeSectTask(taskId) {
  return post('/sect/complete_task', {
    task_id: taskId
  })
}

// 门派贡献
export function contributeSect(amount) {
  return post('/sect/contribute', {
    amount: amount
  })
}

// 伙伴相关
// 获取伙伴列表
export function getPartnerList(upType = 0, pev = null) {
  const payload = { up_type: upType }
  if (pev !== null && pev !== undefined) {
    payload.pev = pev
  }
  return post('/partner/list', payload)
}

// 获取伙伴详情
export function getPartnerDetail(partnerId) {
  return post('/partner/detail', {
    partner_id: parseInt(partnerId)
  })
}

// 招募伙伴
export function recruitPartner(partnerId) {
  return post('/partner/recruit', {
    partner_id: partnerId
  })
}


// 获取伙伴阵容（团队列表）
export function getPartnerTeamList() {
  return post('/partner/team_list')
}

// 更新伙伴阵容（调整队伍成员顺序）
export function partnerJoinTeam(teamId, partnerIds) {
  return post('/partner/join_team', {
    team_id: teamId,
    partner_ids: partnerIds
  })
}

// 获取伙伴图鉴
export function getPartnerPicture() {
  return post('/partner/picture', {})
}

// 兑换五阶兑换令
export function getPartnerExchangeLetter(count) {
  return post('/partner/get_exchange_letter', {
    count: count
  })
}

// 兑换五阶伙伴
export function exchangePartner(partnerId) {
  return post('/partner/exchange_partner', {
    partner_id: partnerId
  })
}

export default {
  getSectList,
  joinSect,
  leaveSect,
  getSectInfo,
  getSectSkills,
  learnSectSkill,
  getSectMembers,
  getSectTasks,
  getSectActivities,
  acceptSectTask,
  completeSectTask,
  contributeSect,
  getPartnerList,
  getPartnerDetail,
  recruitPartner,
  // 新增：伙伴阵容相关接口
  getPartnerTeamList,
  partnerJoinTeam,
  // 新增：图鉴和兑换相关接口
  getPartnerPicture,
  getPartnerExchangeLetter,
  exchangePartner
}